﻿using Commonality.DAL.MySQL;
using Commonality.Model.Classify;
using MathNet.Numerics.LinearAlgebra.Double;
using Merge.BLL;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WZS_Auto_Classifying_Merge
{
    public partial class ClassifyControlForm : Form
    {
        private readonly Timer Timer = new Timer();
        public ClassifyControlForm()
        {
            InitializeComponent();
        }
        #region EigenvectorDataGridView
        private IList<CEigenvector> IClassModels;
        private readonly BindingList<CEigenvector> BClassModel;
        private readonly int EigenvectorCount;
        #endregion


        private void ClassifyControlForm_Load(object sender, EventArgs e)
        {
            //Classify.classifyEngineA = new ClassifyEngine();
            //EigenvectorDataGridViewInit();
            //RefreshData();
            //TimeInit();            
        }
        /// <summary>
        /// 定时器初始化
        /// </summary>
        private void TimeInit()
        {
            Timer.Interval = 500;
            //Timer.Enabled = true;
            Timer.Tick += TimerTick;
        }
        /// <summary>
        /// DataGridView初始化
        /// </summary>
        private void EigenvectorDataGridViewInit()
        {
            EigenvectorDataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            IClassModels = new List<CEigenvector>();
            //EigenvectorCount = Classify.classifyEngineA.ClassModels.Count;
        }
        /// <summary>
        /// 全局类型显示
        /// </summary>
        private void RefreshData()
        {
            //if (EigenvectorCount == Classify.classifyEngineA.ClassModels.Count)
            //{
            //    //特征发生增减才刷新显示
            //    return;
            //}
            //else
            //{
            //    EigenvectorCount = Classify.classifyEngineA.ClassModels.Count;
            //}
            //try
            //{
            //    IClassModels.Clear();
            //    foreach (var item in Classify.classifyEngineA.ClassModels)
            //    {
            //        IClassModels.Add(new CEigenvector(item.Eigenvector.LINEi,
            //                                        item.Eigenvector.PN,
            //                                        item.Eigenvector.KCAndBF,
            //                                        item.Eigenvector.Remark,
            //                                        item.Eigenvector.MEigenvector
            //                                        ));
            //    }

            //    BClassModel = new BindingList<CEigenvector>(IClassModels);
            //    this.Invoke(new EventHandler(delegate
            //    {
            //        this.EigenvectorDataGridView.DataSource = BClassModel;
            //    }));

            //}
            //catch (Exception)
            //{

            //}

        }

        private void TimerTick(object sender, EventArgs e)
        {
            //RefreshData();
        }
    }

}
